package org.ssm.footstep.plugin.device;

import java.awt.Image;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public abstract class IDevice {
	private Set<IDeviceListener> mSetListener = new HashSet<IDeviceListener>();
	
	public enum DEVICE_STATE {
		ONLINE,
		OFFLINE
	}
	
	public abstract void start();
	public abstract void stop();
	
	public abstract DEVICE_STATE getDeviceState();
	
	public abstract Map<String, String> getProperties();
	public abstract String getProperty(String key, String defValue);
	
	public abstract Image getDeviceScreenShot();
	
	public abstract String getDeviceName();
	
	public void addListener(IDeviceListener listener) {
		mSetListener.add(listener);
	}
	
	public void removeListener(IDeviceListener listener) {
		mSetListener.remove(listener);
	}
	
	protected void notifyDeviceScreenShot(Image screenShot) {
		for(IDeviceListener listener : mSetListener) {
			listener.onDeviceScreenShot(screenShot);
		}
	}
	
	protected void notifyDeviceLog(String deviceLog) {
		for(IDeviceListener listener : mSetListener) {
			listener.onDeviceLog(deviceLog);
		}		
	}
}